home *** CD-ROM | disk | FTP | other *** search
Wrap
<!-- #include file="i_utils.asp" --> <% check_security(2) %> <% dim ContentID dim user_id dim ContentTypeID dim CatID dim Title dim Author dim RelatedURL dim DownloadURL dim FileName dim DateAdded dim ShortDesc dim LongDesc dim Display dim EMail dim Expire dim Priority dim Impressions dim ClickThrus dim AvgRating dim Ratings dim edit_content_sql dim ContentType dim Cat dim view_content_sql sub request_edit_content ''' request expected input parameters for this form ContentID = request("ContentID") user_id = request("user_id") ContentTypeID = request("ContentTypeID") CatID = request("CatID") Title = request("Title") Author = request("Author") RelatedURL = request("RelatedURL") DownloadURL = request("DownloadURL") FileName = request("FileName") DateAdded = request("DateAdded") ShortDesc = request("ShortDesc") LongDesc = request("LongDesc") Display = request("Display") EMail = request("EMail") Expire = request("Expire") Priority = request("Priority") Impressions = request("Impressions") ClickThrus = request("ClickThrus") AvgRating = request("AvgRating") Ratings = request("Ratings") end sub sub request_view_content ''' request expected input parameters for this form CatID = request("CatID") ContentTypeID = request("ContentTypeID") user_id = request("user_id") ContentID = request("ContentID") ContentType = request("ContentType") Cat = request("Cat") Title = request("Title") Author = request("Author") DateAdded = request("DateAdded") ShortDesc = request("ShortDesc") Display = request("Display") Priority = request("Priority") Impressions = request("Impressions") ClickThrus = request("ClickThrus") AvgRating = request("AvgRating") end sub sub validate_edit_content ''' request and validate data entered from this form ContentID = trim(request("ContentID")) user_id = trim(request("user_id")) if user_id = "" then error_list.add "487963","User must be specified." b_error = true end if ContentTypeID = trim(request("ContentTypeID")) if ContentTypeID = "" then error_list.add "487950","Content Type must be specified." b_error = true end if CatID = trim(request("CatID")) if CatID = "" then error_list.add "487947","Category must be specified." b_error = true end if Title = trim(request("Title")) if Title = "" then error_list.add "487962","Title must be specified." b_error = true end if Author = trim(request("Author")) RelatedURL = trim(request("RelatedURL")) DownloadURL = trim(request("DownloadURL")) FileName = trim(request("FileName")) DateAdded = trim(request("DateAdded")) if DateAdded <> "" AND (not isdate(DateAdded)) then error_list.add "487951date","Date Added must be a valid date (MM/DD/YY)." b_error = true end if ShortDesc = trim(request("ShortDesc")) if ShortDesc = "" then error_list.add "487961","Description must be specified." b_error = true end if LongDesc = trim(request("LongDesc")) Display = trim(request("Display")) EMail = trim(request("EMail")) Expire = trim(request("Expire")) if Expire <> "" AND (not isdate(Expire)) then error_list.add "487955date","Expire must be a valid date (MM/DD/YY)." b_error = true end if Priority = trim(request("Priority")) if Priority = "" then error_list.add "487958","Priority must be specified." b_error = true end if Impressions = trim(request("Impressions")) ClickThrus = trim(request("ClickThrus")) AvgRating = trim(request("AvgRating")) Ratings = trim(request("Ratings")) end sub sub validate_view_content ''' request and validate data entered from this form CatID = trim(request("CatID")) ContentTypeID = trim(request("ContentTypeID")) user_id = trim(request("user_id")) ContentID = trim(request("ContentID")) ContentType = trim(request("ContentType")) Cat = trim(request("Cat")) Title = trim(request("Title")) Author = trim(request("Author")) DateAdded = trim(request("DateAdded")) if DateAdded <> "" AND (not isdate(DateAdded)) then error_list.add "487978date","Created must be a valid date (MM/DD/YY)." b_error = true end if ShortDesc = trim(request("ShortDesc")) Display = trim(request("Display")) Priority = trim(request("Priority")) Impressions = trim(request("Impressions")) ClickThrus = trim(request("ClickThrus")) AvgRating = trim(request("AvgRating")) end sub sub get_defaults_edit_content ''' set default values for this form DateAdded = "" & now() & "" Display = 1 Priority = 1 Impressions = 0 ClickThrus = 0 Ratings = 0 end sub sub get_defaults_view_content ''' set default values for this form Display = 1 end sub sub db_select_edit_Content sql = "SELECT " & _ "ContentID, " & _ "user_id, " & _ "ContentTypeID, " & _ "CatID, " & _ "Title, " & _ "Author, " & _ "RelatedURL, " & _ "DownloadURL, " & _ "FileName, " & _ "DateAdded, " & _ "ShortDesc, " & _ "LongDesc, " & _ "Display, " & _ "EMail, " & _ "Expire, " & _ "Priority, " & _ "Impressions, " & _ "ClickThrus, " & _ "AvgRating, " & _ "Ratings FROM Content" & _ " WHERE " & _ "Content.ContentID = " & to_sql(ContentID,"number") & "" on error resume next set rs = cn.Execute(sql) if err.number <> 0 then b_error = true error_list.add "select_data_edit_Content", "The data selection failed. " & err.description elseif rs.EOF then b_results = false msg_list.add "select_data_edit_Content", "The record was removed from the database." else ContentID = rs("ContentID") user_id = rs("user_id") ContentTypeID = rs("ContentTypeID") CatID = rs("CatID") Title = rs("Title") Author = rs("Author") RelatedURL = rs("RelatedURL") DownloadURL = rs("DownloadURL") FileName = rs("FileName") DateAdded = rs("DateAdded") ShortDesc = rs("ShortDesc") LongDesc = rs("LongDesc") Display = rs("Display") EMail = rs("EMail") Expire = rs("Expire") Priority = rs("Priority") Impressions = rs("Impressions") ClickThrus = rs("ClickThrus") AvgRating = rs("AvgRating") Ratings = rs("Ratings") end if rs.Close on error goto 0 end sub sub db_insert_edit_Content sql = "INSERT INTO Content" & _ "(" & _ "user_id," & _ "ContentTypeID," & _ "CatID," & _ "Title," & _ "Author," & _ "FileName," & _ "RelatedURL," & _ "DownloadURL," & _ "DateAdded," & _ "ShortDesc," & _ "LongDesc," & _ "Display," & _ "EMail," & _ "Expire," & _ "Priority," & _ "Impressions," & _ "ClickThrus," & _ "AvgRating," & _ "Ratings" & _ ") VALUES (" & _ "" & to_sql(user_id,"number") & "," & _ "" & to_sql(ContentTypeID,"number") & "," & _ "" & to_sql(CatID,"number") & "," & _ "" & to_sql(Title,"text") & "," & _ "" & to_sql(Author,"text") & "," & _ "" & to_sql(FileName,"text") & "," & _ "" & to_sql(RelatedURL,"text") & "," & _ "" & to_sql(DownloadURL,"text") & "," & _ "" & to_sql(now(),"date") & "," & _ "" & to_sql(ShortDesc,"text") & "," & _ "" & to_sql(LongDesc,"text") & "," & _ "" & to_sql(Display,"number") & "," & _ "" & to_sql(EMail,"text") & "," & _ "" & to_sql(Expire,"text") & "," & _ "" & to_sql(Priority,"number") & "," & _ "" & to_sql(Impressions,"number") & "," & _ "" & to_sql(ClickThrus,"number") & "," & _ "" & to_sql(AvgRating,"text") & "," & _ "" & to_sql(Ratings,"number") & ")" & _ "" 'response.write sql on error resume next cn.Execute(sql) if err.Number <> 0 then b_error = true error_list.add "db_insert_edit_Content" & err.Number ,"The database insert failed. " & err.Description else set rs = cn.Execute("SELECT @@IDENTITY") ContentID = rs(0) rs.Close msg_list.add "db_insert_edit_Content","The database insert was successful." end if on error goto 0 end sub sub db_update_edit_Content sql = "UPDATE Content SET " & _ "user_id = " & to_sql(user_id,"number") & ", " & _ "ContentTypeID = " & to_sql(ContentTypeID,"number") & ", " & _ "CatID = " & to_sql(CatID,"number") & ", " & _ "Title = " & to_sql(Title,"text") & ", " & _ "Author = " & to_sql(Author,"text") & ", " & _ "FileName = " & to_sql(FileName,"text") & ", " & _ "RelatedURL = " & to_sql(RelatedURL,"text") & ", " & _ "DownloadURL = " & to_sql(DownloadURL,"text") & ", " & _ "DateAdded = " & to_sql(DateAdded,"text") & ", " & _ "ShortDesc = " & to_sql(ShortDesc,"text") & ", " & _ "LongDesc = " & to_sql(LongDesc,"text") & ", " & _ "Display = " & to_sql(Display,"number") & ", " & _ "EMail = " & to_sql(EMail,"text") & ", " & _ "Expire = " & to_sql(Expire,"text") & ", " & _ "Priority = " & to_sql(Priority,"number") & ", " & _ "Impressions = " & to_sql(Impressions,"number") & ", " & _ "ClickThrus = " & to_sql(ClickThrus,"number") & ", " & _ "AvgRating = " & to_sql(AvgRating,"text") & ", " & _ "Ratings = " & to_sql(Ratings,"number") & " WHERE " & _ "ContentID = " & ContentID & "" 'response.write sql on error resume next cn.execute(sql) if err.number <> 0 then b_error = true error_list.add "db_update_edit_Content" & err.Number ,"The database update failed. " & err.Description else msg_list.add "db_update_edit_Content" & ContentID,"The database update was successful." end if on error goto 0 end sub sub db_delete_edit_Content sql = "DELETE FROM Content" & _ " WHERE " & _ "ContentID = " & to_sql(ContentID,"number") & "" 'response.write sql on error resume next cn.Execute(sql) if err.number <> 0 then b_error = true error_list.add "db_delete_edit_Content" & err.Number ,"The database deletion failed. " & err.Description else msg_list.add "db_delete_edit_Content","The record was removed." end if on error goto 0 end sub sub db_select_view_Content view_Content_sql = "SELECT " & _ "Content.ContentID, " & _ "Content.user_id, " & _ "Content.RegionID, " & _ "Content.ContentTypeID, " & _ "Content.CatID, " & _ "Content.Title, " & _ "Content.Author, " & _ "Content.FileName, " & _ "Content.RelatedURL, " & _ "Content.DownloadURL, " & _ "Content.DateAdded, " & _ "Content.ShortDesc, " & _ "Content.LongDesc, " & _ "Content.Display, " & _ "Content.EMail, " & _ "Content.Expire, " & _ "Content.Priority, " & _ "Content.Impressions, " & _ "Content.ClickThrus, " & _ "Content.AvgRating, " & _ "Content.Ratings, " & _ "ContentTypes.ContentType, Cats.Cat FROM ((Content LEFT JOIN ContentTypes ON Content.ContentTypeID = ContentTypes.ContentTypeID) LEFT JOIN Cats ON Content.CatId = Cats.CatId)" if request("sortby") <> "" AND inStr(lcase(view_Content_sql),"order by") = 0 then view_Content_sql = view_Content_sql + " ORDER BY " & request("sortby") end sub sub db_delete_view_Content sql = "DELETE FROM " & _ "" 'response.write sql on error resume next cn.Execute(sql) if err.number <> 0 then b_error = true end if on error goto 0 end sub do_search = request("do_search") ''' request form keys ContentID = request("ContentID") ''' request action action = lcase(request("action")) ''' action case handler select case action case "select_edit_content" ' select the requested key record from database if ContentID <> "" then db_select_edit_Content else b_error = true error_list.add "edit_edit_Content", "Specify record to select." end if case "insert_edit_content" ' request form data and insert a new record into database validate_edit_content if not b_error then ''' form validation passed, so save record db_insert_edit_content else ''' form validation failed, so re-display form display_edit_content = true end if case "update_edit_content" ' request form data and update an existing database record validate_edit_content if not b_error then if ContentID <> "" then db_update_edit_content else b_error = true error_list.add "update_edit_content", "Specify record to update." end if end if case "delete_edit_content" ' delete the requested key database record if ContentID <> "" then db_delete_edit_content response.redirect request.servervariables("script_name") & "?msg=The+record+was+deleted." else b_error = true error_list.add "delete_edit_content", "Specify record to delete." end if case "display_edit_content" display_edit_content = true end select ' no action was specified, so handle the default case(s) if ContentID <> "" then db_select_edit_Content display_edit_Content = true end if ':: list all content db_select_view_Content %> <!-- #include file='i_header.asp' --> <!-- #include file='i_menu.asp' --> <!-- #include file="i_menu_admin.asp" --> <% display_errs display_msg %> <br> <! -- only display the edit form when the grid form is not displayed --> <% if ContentID <> "" OR display_edit_content then %>[<A HREF='admin_content.asp'>view all</A>] <table class='headerTable'> <tr> <td class='headerTD'> Edit Content </td> </tr> </table> <table > <form name="edit_Content" action="admin_content.asp" method="post" > <input type=hidden name="ContentID" value="<% =ContentID %>"> <tr> <td class='labelTD'>User</td> <td class='dataTD' > <select name="user_id" > <option></option> <% =get_options ("SELECT user_id, user_name FROM Users", user_id) %> </select> </td> </tr> <tr> <td class='labelTD'>Content Type</td> <td class='dataTD' > <select name="ContentTypeID" > <option></option> <% =get_options ("SELECT ContentTypeID, ContentType FROM ContentTypes", ContentTypeID) %> </select> <A href='admin_contenttypes.asp'>Edit Types..</A> </td> </tr> <tr> <td class='labelTD'>Category</td> <td class='dataTD' > <select name="CatID" > <option></option> <% =get_options ("SELECT Cats3.CatId, Cats.Cat, Cats1.Cat, Cats2.Cat, Cats3.Cat FROM (((Cats As Cats3 left JOIN Cats As Cats2 ON Cats3.ParentId = Cats2.CatId) left JOIN Cats As Cats1 ON Cats2.ParentId = Cats1.CatId) LEFT JOIN Cats As Cats ON Cats1.ParentId = Cats.CatId) WHERE Cats.ParentId is NULL order by (Cats.Cat & Cats1.Cat & Cats2.Cat & Cats3.Cat)", CatID) %> </select> </td> </tr> <tr> <td class='labelTD'>Title</td> <td class='dataTD' > <input type=text name="Title" size="" maxlength="50" value="<% =Title%>"> </td> </tr> <tr> <td class='labelTD'>Author</td> <td class='dataTD' > <input type=text name="Author" size="" maxlength="50" value="<% =Author%>"> </td> </tr> <tr> <td class='labelTD'>Related URL</td> <td class='dataTD' > <input type=text name="RelatedURL" size="" maxlength="70" value="<% =RelatedURL%>"> </td> </tr> <tr> <td class='labelTD'>Download URL</td> <td class='dataTD' > <input type=text name="DownloadURL" size="" maxlength="50" value="<% =DownloadURL%>"> </td> </tr> <tr> <td class='labelTD'>Filename</td> <td class='dataTD' > <input type=text name="FileName" size="" maxlength="" value="<% =FileName%>"> </td> </tr> <tr> <td class='labelTD'>Date Added</td> <td class='dataTD' > <% =DateAdded %> </td> </tr> <tr> <td class='labelTD'>Description</td> <td class='dataTD' > <textarea name="ShortDesc" rows='6' cols='50'><% =ShortDesc%></textarea> </td> </tr> <tr> <td class='labelTD'>Content</td> <td class='dataTD' > <textarea name="LongDesc" rows='20' cols='90'><% =LongDesc%></textarea> </td> </tr> <tr> <td class='labelTD'>Display</td> <td class='dataTD' > <% if Display = "" then Display = false %> <input type=checkbox <% if Display then %>checked<% end if %> name="Display" value="1"> </td> </tr> <tr> <td class='labelTD'>EMail</td> <td class='dataTD' > <input type=text name="EMail" size="" maxlength="50" value="<% =EMail%>"> </td> </tr> <tr> <td class='labelTD'>Expire</td> <td class='dataTD' > <input type=text name="Expire" size="" maxlength="10" value="<% =Expire%>"> </td> </tr> <tr> <td class='labelTD'>Priority</td> <td class='dataTD' > <% if not isnull(Priority) then if (Priority < 1) AND (not Priority) then Priority = 0 else Priority = 0 end if %> <select name="Priority" > <option></option> <option <% if "1" = cStr(Priority) then %>selected<% end if %> value="1">1-standard</option> <option <% if "2" = cStr(Priority) then %>selected<% end if %> value="2">2-priority</option> <option <% if "3" = cStr(Priority) then %>selected<% end if %> value="3">3-premier</option> </select> </td> </tr> <tr> <td class='labelTD'>Impressions</td> <td class='dataTD' > <% =Impressions %> </td> </tr> <tr> <td class='labelTD'>Click-thrus</td> <td class='dataTD' > <% =ClickThrus %> </td> </tr> <tr> <td class='labelTD'>Avg Rating</td> <td class='dataTD' > <% =AvgRating %> </td> </tr> <tr> <td class='labelTD'>Ratings</td> <td class='dataTD' > <% =Ratings %> </td> </tr> <tr> <td class=labelTD align=right> <% if ContentID <> "" then %><% end if %> </td> <td class=dataTD> <% if ContentID = "" then %><input type=submit name=insert_button value='INSERT'><% end if %> <% if ContentID <> "" then %><input type=submit name=update_button value='UPDATE'><% end if %> <% if ContentID <> "" then %><input type=submit name=delete_button value='DELETE' onclick="document.edit_Content.action.value = 'delete_edit_Content'"><% end if %> </td> <input type=hidden name="action" value="<% if ContentID <> "" then %>update<% else %>insert<%end if %>_edit_Content"></tr> </form> </table> <% end if %> <! -- only display the grid when the edit form is not displayed --> <br> <% if display_edit_Content <> true then %>[<A HREF='admin_content.asp?action=display_edit_Content'>add new article</A>] <% page_no = request("page_no") if page_no = "" then page_no = 1 if view_Content_sql <> "" then cmd.CommandText = view_Content_sql rs.Filter = "" rs.CursorLocation = 3 rs.CacheSize = 5 rs.Open cmd if not rs.EOF then rs.MoveFirst rs.PageSize = 20 max_count = cInt(rs.PageCount) num_recs = rs.RecordCount rs.AbsolutePage = page_no results = true else results = false rs.Close end if else results = false end if rec_count = 0 %> <table class='headerTable'> <tr> <td class='headerTD'> Existing Content </td> </tr> </table> <% if results = true then %> <table > <form name="view_Content" action="admin_content.asp" method="get" > <tr> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=ContentID" class=fieldFont title="">#</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=ContentType" class=fieldFont title="">Content Type</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Cat" class=fieldFont title="">Category</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Title" class=fieldFont title="">Title</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Author" class=fieldFont title="">Author</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=DateAdded" class=fieldFont title="">Created</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=ShortDesc" class=fieldFont title="">Description</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Display" class=fieldFont title="">Display</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Priority" class=fieldFont title="">Priority</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Impressions" class=fieldFont title="">Views</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=ClickThrus" class=fieldFont title="">Clicks</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=AvgRating" class=fieldFont title="">Rating</a></td> </tr> <% do while not rs.EOF AND (rec_count < rs.Pagesize) ':: read db record on error resume next CatID = rs("CatID") ContentTypeID = rs("ContentTypeID") user_id = rs("user_id") ContentID = rs("ContentID") ContentType = rs("ContentType") Cat = rs("Cat") Title = rs("Title") Author = rs("Author") DateAdded = rs("DateAdded") ShortDesc = rs("ShortDesc") Display = rs("Display") Priority = rs("Priority") Impressions = rs("Impressions") ClickThrus = rs("ClickThrus") AvgRating = rs("AvgRating") on error goto 0 %> <input type=hidden name="CatID" value="<% =CatID %>"> <input type=hidden name="ContentTypeID" value="<% =ContentTypeID %>"> <input type=hidden name="user_id" value="<% =user_id %>"> <tr> <td class='dataTD' > <a href="admin_content.asp?ContentID=<%=ContentID%>"><% =ContentID %></a> </td> <td class='dataTD' nowrap> <% =ContentType %> </td> <td class='dataTD' nowrap> <% =Cat %> </td> <td class='dataTD' > <a href="admin_content.asp?ContentID=<%=ContentID%>"><% =Title %></a> </td> <td class='dataTD' > <% if user_id <> "" then %>[<a href='admin_users.asp?user_id=<% =user_id %>'><% end if %><% =Author %><% if user_id <> "" then %></A>]<% end if %> </td> <td class='dataTD' width=140 nowrap> <% =DateAdded %> </td> <td class='dataTD' > <% ShortDesc = left(ShortDesc,55) %><% =ShortDesc %>... </td> <td class='dataTD' > <% =Display %> </td> <td class='dataTD' > <% =Priority %> </td> <td class='dataTD' > <% =Impressions %> </td> <td class='dataTD' > <% =ClickThrus %> </td> <td class='dataTD' > <% =AvgRating %> </td> </tr> <% rs.MoveNext rec_count = rec_count + 1 loop rs.Close %> </form> </table> <% else %> no matches were found. <% end if %> <% if max_count > 1 then %> <!-- paging footer --> <TABLE class=HeaderTable > <tr> <td width="20%" class=HeaderTD> <% if page_no > 1 then %> <a class=HeaderFont href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no-1 %>&sortby=<% =request("sortby") %>">PREV</a> <% else %> <% end if %> </td> <td align=center class=HeaderTD> Page <% for i = 1 to max_count %> <% if i = cint(page_no) then %> <b><%=i%></b> <% else %> <a class=HeaderFont href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =i %>&sortby=<% =request("sortby") %>"><%=i%></a> <% end if %> <%next %> </td> <td align=right width="20%" class=HeaderTD> <% if cInt(page_no) < cInt(max_count) then %> <a class=HeaderFont href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no+1 %>&sortby=<% =request("sortby") %>">NEXT</a> <% end if %> </td> </tr> </TABLE> <% end if %> <% end if %> <!-- #include file=i_footer.asp --> <% ':: assure that any db resources are freed on error resume next rs.Close set rs = NOTHING cn.Close set cn = NOTHING user_cn.Close set user_cn = NOTHING on error goto 0 %>